package com.woniuxy.controller;


import com.woniuxy.controller.form.*;
import com.woniuxy.exception.DdException;
import com.woniuxy.service.PawnAttrConfService;
import com.woniuxy.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hujianying
 * @since 2022-03-23
 */
@RestController
@RequestMapping("/pawnAttrConf")
@Api(tags = "属性组参数相关接口")
public class PawnAttrConfController {

    @Resource
    private PawnAttrConfService pacs;

    /**
     * 根据属性组id查询所有对应的属性配置
     * @param fcf groupCode
     * @return findConfInfo
     */
    @ApiOperation("根据属性组id查询所有对应的属性配置")
    @GetMapping("/getAllConfByGroupCode")
    public Result getAllConfByGroupCode(FindConfForm fcf){
        return pacs.getAllConfByGroupCode(fcf);
    }

    /**
     * 模糊查询
     * @param fcf str
     * @return findConfInfo
     */
    @ApiOperation("模糊查询")
    @GetMapping("/getConfByLike")
    public Result getConfByLike(FindConfForm fcf){
        return pacs.getConfByLike(fcf);
    }

    /**
     * 根据被选中的属性删除
     * @param dcf isChecked
     * @return data为null
     */
    @ApiOperation("根据被选中的属性删除")
    @PostMapping("/deleteByChecked")
    public Result deleteByChecked(@RequestBody DeleteConfForm dcf) throws DdException {
        return pacs.deleteByChecked(dcf);
    }

    /**
     * 根据attrCode获取conf
     * @param gocf attrCode
     * @return
     */
    @ApiOperation("根据attrCode获取conf")
    @GetMapping("/getConfByAttrCode")
    public Result getConfByAttrCode(GetOneConfForm gocf){
        return pacs.getConfByAttrCode(gocf);
    }


    /**
     * 修改属性参数
     * @param ucf UpdateConfForm
     * @return data为null
     */
    @ApiOperation("修改属性参数")
    @PostMapping("/updateConf")
    public Result updateConf(@RequestBody UpdateConfForm ucf){
        return pacs.updateConf(ucf);
    }

    /**
     * 新增属性参数
     * @param scf saveConfForm
     * @return data为null
     */
    @ApiOperation("新增属性参数")
    @PostMapping("/saveConf")
    public Result saveConf(@RequestBody SaveConfForm scf) throws DdException {
        return pacs.saveConf(scf);
    }

    /**
     * 根据大类code获取属性组参数
     * @param gcbccf catCode
     * @return GetConfByCatCodeInfo
     */
    @ApiOperation("根据大类code获取属性组参数")
    @GetMapping("/getConfByGroupName")
    public Result getConfByGroupName(GetConfByCatCodeForm gcbccf){
        return pacs.getConfByPcatCode(gcbccf);
    }
}

